<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->
	<link href="/public/simpleboot/themes/<?php echo C('SP_ADMIN_STYLE');?>/theme.min.css" rel="stylesheet">	
    <link href="/public/simpleboot/css/simplebootadmin.css" rel="stylesheet">
    <link href="/public/js/artDialog/skins/default.css" rel="stylesheet" />
    <link href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome.min.css"  rel="stylesheet" type="text/css">
    <style>
		form .input-order{margin-bottom: 0px;padding:3px;width:40px;}
		.table-actions{margin-top: 5px; margin-bottom: 5px;padding:0px;}
		.table-list{margin-bottom: 0px;}
	</style>
	<!--[if IE 7]>
	<link rel="stylesheet" href="/public/simpleboot/font-awesome/4.4.0/css/font-awesome-ie7.min.css">
	<![endif]-->
	<script type="text/javascript">
	//全局变量
	var GV = {
	    ROOT: "/",
	    WEB_ROOT: "/",
	    JS_ROOT: "public/js/",
	    APP:'<?php echo (MODULE_NAME); ?>'/*当前应用名*/
	};
	</script>
    <script src="/public/js/jquery.js"></script>
    <script src="/public/js/wind.js"></script>
    <script src="/public/simpleboot/bootstrap/js/bootstrap.min.js"></script>
    <script>
    	$(function(){
    		$("[data-toggle='tooltip']").tooltip();
    	});
    </script>
<?php if(APP_DEBUG): ?><style>
		#think_page_trace_open{
			z-index:9999;
		}
        input[type=text]{
            height: 18px!important;
        }
        select{
            width: 160px;
        }
	</style><?php endif; ?>
</head>
<body>
	<div class="wrap js-check-wrap">

		<ul class="nav nav-tabs">
			<li><a href="<?php echo U('Goods/goods_list');?>">商品列表</a></li>
			<li class="active"><a>商品添加</a></li>
		</ul>
        <form class="form-horizontal js-ajax-forms" action="<?php echo U('Goods/goods_edit_act');?>" method="post">
			<fieldset>
				<div class="tabbable">
					<div class="tab-content">
							<fieldset>
								<div class="control-group">
									<label class="control-label">商品名称</label>
									<div class="controls">
										<input type="text" name="title" value="<?php echo ((isset($list['title']) && ($list['title'] !== ""))?($list['title']):''); ?>">
										<input type="hidden" name="id" value="<?php echo ((isset($list['id']) && ($list['id'] !== ""))?($list['id']):''); ?>">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品描述</label>
									<div class="controls">
										<input type="text" name="subtitle" value="<?php echo ((isset($list['subtitle']) && ($list['subtitle'] !== ""))?($list['subtitle']):''); ?>">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">额度选择</label>
									<div class="controls">
										<select id="ck_bond">
											<option value="">有无保证金</option>
											<option value="0">无保证金</option>
											<option value="1">有保证金</option>
										</select>
										<select name="amount_id" id='amount' onchange='ck()'>
											<?php if(is_array($amount_list)): foreach($amount_list as $key=>$vo): $tpl_selected=($list['amount']==$vo['amount'] && $list['interest']==$vo['interest'] && $list['examine']==$vo['examine'] && $list['consulting']==$vo['consulting'] && $list['bond_amount']==$vo['bond_amount'])?"selected":""; ?>
											<option <?php echo ($tpl_selected); ?> value="<?php echo ($vo["id"]); ?>">
												<?php echo ($vo["name"]); ?>
												<?php if($vo['bond_amount']>0){ echo '---有保证金'; }else{ echo '---无保证金'; } ?>
											</option><?php endforeach; endif; ?>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">额度</label>
									<div class="controls"><input type="text" name="amount" id='dqf' value="<?php echo ($list["amount"]); ?>" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">咨询费</label>
									<div class="controls"><input type="text" name="interest" id='zxf' value="<?php echo ((isset($list["interest"]) && ($list["interest"] !== ""))?($list["interest"]):''); ?>" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">审核费</label>
									<div class="controls"><input type="text" name="examine" id='shf' value="<?php echo ((isset($list["examine"]) && ($list["examine"] !== ""))?($list["examine"]):''); ?>" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">顾问费</label>
									<div class="controls"><input type="text" name="consulting" id='gwf' value="<?php echo ((isset($list["consulting"]) && ($list["consulting"] !== ""))?($list["consulting"]):''); ?>" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">保证金</label>
									<div class="controls"><input type="text" name="bond_amount" id='bzj' value="<?php echo ((isset($list["bond_amount"]) && ($list["bond_amount"] !== ""))?($list["bond_amount"]):''); ?>" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">颜色</label>
									<div class="controls">
										<input type="text" name="color" value="<?php echo ((isset($list['color']) && ($list['color'] !== ""))?($list['color']):''); ?>">*用逗号隔开
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">规格</label>
									<div class="controls">
										<input type="text" name="spec" value="<?php echo ((isset($list['spec']) && ($list['spec'] !== ""))?($list['spec']):''); ?>">*用逗号隔开
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">租赁最小周期(周)</label>
									<div class="controls">
										<input type="text" name="startime" value="<?php echo ((isset($list['startime']) && ($list['startime'] !== ""))?($list['startime']):''); ?>">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">租赁最大周期(周)</label>
									<div class="controls">
										<input type="text" name="endtime" value="<?php echo ((isset($list['endtime']) && ($list['endtime'] !== ""))?($list['endtime']):''); ?>">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品banner图</label>
									<div class="controls">
										<ul id="photos" class="pic-list unstyled">
											<?php if(!empty($list['url'])): if(is_array($list['url'])): foreach($list['url'] as $key=>$vo): if($vo['type'] == 2): $img_url=sp_get_image_preview_url($vo['url']); ?>
												<li id="savedimage<?php echo ($key); ?>">
													<input id="photo-<?php echo ($key); ?>" type="hidden" name="photos_url[]" value="<?php echo ($vo['url']); ?>"> 
													<img id="photo-<?php echo ($key); ?>-preview" src="<?php echo ($img_url); ?>" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
													<a href="javascript:upload_one_image('图片上传','#photo-<?php echo ($key); ?>');">替换</a>
													<a href="javascript:(function(){ $('#savedimage<?php echo ($key); ?>').remove();})();">移除</a>
												</li><?php endif; endforeach; endif; endif; ?>
										</ul>
										<a href="javascript:upload_multi_image('图片上传','#photos','photos-item-wrapper');" class="btn btn-small">选择图片</a>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品详情图</label>
									<div class="controls">
										<ul id="pbc" class="pic-list unstyled">
											<?php if(!empty($list['url'])): if(is_array($list['url'])): foreach($list['url'] as $key=>$vo): if($vo['type'] == 3): $img_url=sp_get_image_preview_url($vo['url']); ?>
												<li id="pbc<?php echo ($key); ?>">
													<input id="pbc-<?php echo ($key); ?>" type="hidden" name="pbc_url[]" value="<?php echo ($vo['url']); ?>"> 
													<img id="pbc-<?php echo ($key); ?>-preview" src="<?php echo ($img_url); ?>" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
													<a href="javascript:upload_one_image('图片上传','#pbc-<?php echo ($key); ?>');">替换</a>
													<a href="javascript:(function(){ $('#pbc<?php echo ($key); ?>').remove();})();">移除</a>
												</li><?php endif; endforeach; endif; endif; ?>
										</ul>
										<a href="javascript:upload_multi_image('图片上传','#pbc','photos-item-wrapper-bs');" class="btn btn-small">选择图片</a>
									</div>
								</div>
							</fieldset>
					</div>
				</div>

				<div class="form-actions">
					<button type="submit" class="btn btn-primary  js-ajax-submit"><?php echo L("SAVE");?></button>
				</div>
			</fieldset>
		</form>
		
	</div>
	<script src="/public/js/common.js"></script>
<script type="text/html" id="photos-item-wrapper">
<li id="savedimage{id}">
	<input id="photo-{id}" type="hidden" name="photos_url[]" value="{filepath}"> 
	<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
	<a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
	<a href="javascript:(function(){$('#savedimage{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="photos-item-wrapper-bs">
<li id="pbcsavedimage{id}">
	<input id="pbc-{id}" type="hidden" name="pbc_url[]" value="{filepath}"> 
	<img id="pbc-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
	<a href="javascript:upload_one_image('图片上传','#pbc-{id}');">替换</a>
	<a href="javascript:(function(){$('#pbcsavedimage{id}').remove();})();">移除</a>
</li>
</script>
<script>
	$('#ck_bond').change(function(){
		if($(this).val()!=''){
			var flag = parseInt($(this).val()) === 1;
			if(flag){
				$('#amount').find('option').each(function(){
					if($(this).text().indexOf("有保证金")>0){
						$(this).show();
					}else{
						$(this).hide();
					}
				});
			}else{
				$('#amount').find('option').each(function(){
					if($(this).text().indexOf("无保证金")>0){
						$(this).show();
					}else{
						$(this).hide();
					}
				});
			}
		}
	});
	function ck(){
		var id=$("#amount").val();
		switch (id){
			<?php if(is_array($amount_list)): foreach($amount_list as $key=>$vo): ?>case '<?php echo ($vo["id"]); ?>':
				document.getElementById('zxf').value='<?php echo ($vo["interest"]); ?>元';
				document.getElementById('shf').value='<?php echo ($vo["examine"]); ?>元';
				document.getElementById('gwf').value='<?php echo ($vo["consulting"]); ?>元';
				document.getElementById('dqf').value="<?php echo ($vo['amount']); ?>元";
				<?php if(empty($vo['bond_amount'])){ $vo['bond_amount']=0; } ?>
				document.getElementById('bzj').value="<?php echo ($vo['bond_amount']); ?>元";
				break;<?php endforeach; endif; ?>
		}
	}
</script>
</body>
</html>